  

#include<iostream>
using namespace std;


void swap01(int a1, int a2)
{
      int tmp = a1;
      a1 = a2;
      a2 = tmp;

      cout<<"a1的值为："<<a1<<endl;
      cout<<"a2的值为："<<a2<<endl;
}

void swap02(int * a1, int *a2)
{
      int tmp = *a1;
      *a1 = *a2;
      *a2 = tmp;

      cout<<"a1的值为："<<*a1<<endl;
      cout<<"a2的值为："<<*a2<<endl;
}

  int maina02()
  {
    
        int x = 10;
        
        // 定义指针
        int *p;

        //指针指向a的内存
        p = &x;

        //解引用修改a的内存

        *p  = 200;

         cout<<"a的值为:"<<x<<endl;
         cout<<"p的值为:"<<*p<<endl;

        //空指针

        int *pt = NULL;

      //空指针不能直接访问
       //*pt = 100;
     //  cout << "*pt="<<*pt<<endl;

     
       int y = 1000;
       pt = &y;
       cout << "pt="<<pt<<endl;
     *pt = 500000000;
     cout << "*pt="<<*pt<<endl;

     int arr[10] = {1,2,3,4,5,6,7,8,9,10};

     int *k = arr;

     cout <<"数组的值："<<*k<<endl;
     int a1 = 10;
     int a2 = 20;

      cout<<"==========对比变化==========="<<endl;
      swap01(a1,a2);
       cout<<"a1的值为："<<a1<<endl;
      cout<<"a2的值为："<<a2<<endl;

        cout<<"==========对比变化==========="<<endl;
       swap02(&a1,&a2);
       cout<<"=========================="<<endl;
       cout<<"a1的值为："<<a1<<endl;
      cout<<"a2的值为："<<a2<<endl;


















        return 0;




  }